import { createStore } from 'vuex'
const shouldUseTransition = !/transition=none/.test(location.href)
import { getCookie } from '@/utils/cookie.js'
export default createStore({
    state: {
        isLoading: false,
        direction: '',
        demoScrollTop: 0,
        userinfo: getCookie('userinfo') || {},
    },
    mutations: {
        updateDemoPosition(state, payload) {
            state.demoScrollTop = payload.top
        },
        updateLoadingStatus(state, payload) {
            state.isLoading = payload.isLoading
        },
        updateDirection(state, payload) {
            if (!shouldUseTransition) {
                return
            }
            state.direction = payload.direction
        },
    },
    actions: {
        updateDemoPosition({ commit }, top) {
            commit({ type: 'updateDemoPosition', top: top })
        },
    },
    modules: {},
})
